package com.gexin.model.activity;

import com.gexin.common.utils.BigDecimalUtils;
import com.gexin.model.activity.base.BaseMemberOrder;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 业务名称:  t_member_order()
 */
@SuppressWarnings("serial")
public class MemberOrder extends BaseMemberOrder<MemberOrder> {
    public static final MemberOrder dao = new MemberOrder();

    public void setOrderIdAndBillIntegralAndAcquireAndDailyIncrementAndForecastIntegralAndRemainIntegralAndMultiRuleAndStatus(
            String orderId, BigDecimal billIntegral,  BigDecimal acquireIntegral, BigDecimal dailyIncrement,
            BigDecimal forecastIntegral, BigDecimal remainIntegral, BigDecimal multiply,int status) {
        this.setId(UUID.randomUUID() + "");
        this.setOrderId(orderId);
        this.setStatus(status);
        this.setBillIntegral(billIntegral);
        this.setDeliverMultiple(multiply);
        this.setAcquiredIntegral(acquireIntegral);
        this.setDailyIncrement(dailyIncrement);
        this.setForecastIntegral(forecastIntegral);
        this.setRemainIntegral(remainIntegral);
        Long date = new Date().getTime();
        this.setCreateTime(date);
        this.setUpdateTime(date);
    }


    public void setAcquiredIntegralAndForcastIntegralAndDailyIncrementAndRemainIntegralAndStatus(
            BigDecimal dailyIncrement, BigDecimal acquireIntegral,
            BigDecimal forecastIntegral, BigDecimal remainIntegral, BigDecimal multiple, int status
    ) {
        this.setAcquiredIntegral(acquireIntegral);
        this.setDailyIncrement(dailyIncrement);
        this.setForecastIntegral(forecastIntegral);
        this.setRemainIntegral(remainIntegral);
        this.setDeliverMultiple(multiple);
        this.setAcquiredIntegral(acquireIntegral);
        this.setStatus(status);
        long date = new Date().getTime();
        this.setUpdateTime(date);
    }

    public List<MemberOrder> findByOrderIdByStatus(int status) {
        List<MemberOrder> memberOrders = MemberOrder.dao.find("select * from t_member_order where status="
                + status +" order by create_time desc");

        return memberOrders;
    }

    public MemberOrder findByOrderId(String orderId) {
        MemberOrder memberOrders = MemberOrder.dao.findFirst("select * from t_member_order where order_id=" + orderId + " for update");
        return memberOrders;
    }

    public void setUserIdAndBillAndItemIdAndDailyMultipleAndAcquireIntegralAndRemainIntegralAndForcastSpeed(String s, String userId, BigDecimal valueOf, String s1, BigDecimal zero, BigDecimal zero1, BigDecimal forcastIntegral, BigDecimal forcastIntegral1, BigDecimal multiRule, int code) {
    }

    public List<MemberOrder> getMemberOrderByUserId(String userId) {
        List<MemberOrder> memberOrderIntegrals = MemberOrder.dao.find("select * from t_member_order " +
                "where user_id=" + userId + " order by create_time desc");
        return memberOrderIntegrals;
    }

    public List<MemberOrder> findByOrder(String userId) {
        List<MemberOrder> memberOrders = MemberOrder.dao.find("select * from t_member_order order by create_time desc");
        return memberOrders;
    }


    public List<MemberOrder> getMemberOrderList(String id){
        List<MemberOrder> memberOrderList=MemberOrder.dao.find("select * from t_member_order where user_id="+id);
        return memberOrderList;
    }

    public MemberOrder getMemberByUserIdAndStatus(String userId,int status) {
        MemberOrder memberOrder = MemberOrder.dao.findFirst("select t_member_order.* from " +
                "t_member_order join t_order on t_member_order.order_id=t_order.id where t_order.user_id="
                + userId+" and t_member_order.status="+status);
        return memberOrder;
    }

}
